import Vue from 'vue'
import App from './App'
import router from '@/router/index.js'
import store from '@/store/index.js'
import mixins from '@/mixins/index.js'
import filters from '@/filters/index.js'

// 挂载全局mixin
Vue.mixin(mixins)

// 挂载全局filters
Object.keys(filters).forEach(v => {
	Vue.filter(v, filters[v])
})

Vue.config.productionTip = false

// token持久登录
const token = uni.getStorageSync('token')
if(token) {
	store.commit('user/SET_TOKEN', {token})
}

App.mpType = 'app'
Vue.prototype.$store = store
Vue.prototype.$r = router
Vue.prototype.$logger = (log, name = 'log', isShow = true) => {
	if(isShow){
		console.log(name + ' ===> ', log)
	}
}

const app = new Vue({
	store,
    ...App
})
app.$mount()
